﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using FooFun.DataElements.Dtos;

namespace FooFun.Web.Controls
{
    public class ResolveUrl : DataElementControl
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            this.DataElement = new LinkDataElement(this);
        }

        class LinkDataElement : DataElement
        {
            Control ctr;
            public LinkDataElement(Control ctr)
            {
                this.ctr = ctr;
            }

            public override IDataElement this[string key]
            {
                get
                {
                    string url = ctr.ResolveClientUrl(key);
                    return new StringDataElement(url);
                }
            }
        }
    }
}
